package order

import (
	"API/client"
	"API/response"
	"common/utils"
	"github.com/gin-gonic/gin"
	order "order_server/proto"
)

// CreateOrder 订单创建
func CreateOrder(c *gin.Context) {
	userId := c.GetUint("userId")
	create, err := client.OrderCreate(c, &order.OrderCreateRequest{
		Uid: int64(userId),
	})
	if err != nil {
		response.CurrencyErrResponse(c, -1, utils.CutOutRpcError(err.Error()))
		return
	}
	response.CurrencySuccessResponse(c, "创建成功", map[string]interface{}{
		"orderId": create.OrderId,
		"url":     create.Url,
	})
}
